package com.drone.drone_server.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.drone.drone_server.entity.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

// 无人机DAO
public interface DroneDao extends BaseMapper<Drone> {
    @Select("SELECT * FROM drone WHERE status = #{status}")
    List<Drone> selectByStatus(@Param("status") String status);

    @Select("SELECT * FROM drone WHERE model = #{model}")
    List<Drone> selectByModel(@Param("model") String model);

    @Select("SELECT drone_id FROM drone")
    List<Integer> selectAllIds();


    // 在DroneDao接口中添加
    @Update("UPDATE drone SET status = #{status} WHERE drone_id = #{droneId}")
    int updateStatus(@Param("droneId") Integer droneId,
                     @Param("status") Drone.Status newStatus);


}